<html>
<head>
<meta http-equiv='content-type' content='text/html; charset=utf-8' >
<link rel="stylesheet" href="../web/styl.css" />
<script src='../js/prototype.js' ></script>
<script src='../js/datadumper.js' ></script>
<script src='../js/kato.js' ></script>
</head>
<body onload='Kato.Init({BaseUrl:".."});'>

<script>

function update_dicts(view, id, row_index) {
	if (view.rows[row_index][view.model.col_name_to_index('id_custom_column_type')] != '3') {
		Element.hide('dicts');
	} else {
		Element.show('dicts');
	}
}

function choose_table(view, id, row_index) {
	Kato.Active.custom_columns_tabelka.render({search_table_name:id});
	Kato.Active.custom_columns_formularz.render({search_table_name:id});
	Element.hide('dicts');
}

</script>

<h1>Custom columns</h1>

<h2>Tables</h2>

<div id="custom_columns_lista"
	kato_type="Kato.Grid"
	kato_server_params="'orderby_table_name'"
	kato_params_template="orderby_table_name:'asc'"
	kato_model="tables_with_custom_columns_v"
	kato_onchange_handlers="choose_table"
>
</div>

<h2>Columns</h2>

<div id="custom_columns_tabelka"
	kato_type="Kato.Grid"
	kato_model="custom_columns_v"
	kato_server_params="'orderby_table_name','search_table_name'"
	kato_params_template="orderby_table_name:'asc',search_table_name:null"
	kato_onclick_notify_children="'custom_columns_formularz','dict_tabelka','dict_formularz'"
	kato_onchange_handlers="update_dicts"
>
</div>

<div id="custom_columns_formularz"
	kato_type="Kato.Form"
	kato_model="custom_columns_v"
	kato_server_params="'search_id_custom_column'"
	kato_params_template="search_id_custom_column:null"
	kato_custom_cell_renderers="
		id_custom_column_type:'dropdown'
	"
	kato_visible_columns="
		'custom_column_name', 'id_custom_column_type'
	"
>
</div>

<div id="dicts" style="display: none">
<h2>Dictionaries</h2>

<div id="dict_tabelka"
	kato_type="Kato.Grid"
	kato_model="custom_dicts_v"
	kato_server_params="'search_id_custom_column'"
	kato_params_template="search_id_custom_column:null"
	kato_onclick_notify_children="'dict_formularz'"
	kato_visible_columns="'value1'"
>
</div>

<div id="dict_formularz"
	kato_type="Kato.Form"
	kato_model="custom_dicts_v"
	kato_server_params="'search_id_custom_column','value'"
	kato_params_template="search_id_custom_column:null,search_value:null"
	kato_visible_columns="'value1'"
>
</div>
</div>

</body>
</html>
